import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.JButton;
import javax.swing.JTextField;
import javax.swing.JLabel;
import javax.swing.Box;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class Dialogue extends JDialog implements ActionListener {
 /**
	 * 
	 */
	private static final long serialVersionUID = 1L;
Graphe g;
 JButton valider = new JButton("Valider");
 JButton annuler = new JButton("Annuler");
 JTextField champNom = new JTextField(10);
 public Dialogue(Graphe g) {
	this.g = g;
	JPanel panneau ;
	
	Box boite = Box.createVerticalBox();
	setModal(true);
	setTitle("Operation Sommet");
	panneau = new JPanel();
	panneau.add(new JLabel("nom de la page: "));
	panneau.add(champNom);
	boite.add(panneau);
	
	panneau = new JPanel();
	panneau.add(valider);
	panneau.add(annuler);
	boite.add(panneau);
	
	add(boite) ;
	
	valider.addActionListener(this);
	annuler.addActionListener(this);
	pack();
	setLocation(400, 200);
	setVisible(true);
 }
 
 public void actionPerformed(ActionEvent evt) {
	Object source = evt.getSource();
	if (source == valider) {
	Sommet s1=new Page(champNom.getText());
    g.ajouterSom(s1);
	dispose();
	Menu.panel.setVisible(true);
	Menu.fenetre.setVisible(true);
	}
	else if (source == annuler) { 
	dispose();
	Menu.panel.setVisible(true);
	Menu.fenetre.setVisible(true);
}
}
}

